<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>按从大到小排序</title>
</head>

<body>
    <script>
        var arr = new Array(70, 35, 67, 49, 20, 59, 98, 100);
        for (var i = 1; i < arr.length; i++) {
            for (var j = 0; j < arr.length - i; j++) {
                if (arr[j] < arr[j + 1]) {
                    var flat = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = flat;
                }
            }
        }
        alert(arr);
        alert(arr[0]);
        alert(arr[7]);
    </script>

</body>

</html>